package com.msti.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.msti.entity.Batch;
import com.msti.entity.Course;
import com.msti.service.BatchMgtDAO;
import com.msti.service.BatchMgtDAOImpl;
import com.msti.service.CourseMgtDAO;
import com.msti.service.CourseMgtDAOImpl;

/**
 * Servlet implementation class EditCourses
 */
public class EditCourses extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EditCourses() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		CourseMgtDAO courseMgtDAO = new CourseMgtDAOImpl();
		List<Course> courses = new ArrayList<Course>();
		courses = courseMgtDAO.getAllCourse();
		request.setAttribute("courses", courses);
		RequestDispatcher requestDispatcher = request.getRequestDispatcher("EditCourses.jsp");
		requestDispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		CourseMgtDAO courseMgtDAO = new CourseMgtDAOImpl();
		String cId = request.getParameter("courseId");
		System.out.println(request.getParameter("id"));
		RequestDispatcher requestDispatcher = request.getRequestDispatcher("adminPage.jsp");
		requestDispatcher.forward(request, response);
	}

}
